package com.hdyg.sixg.mvp.presenter;

import com.hdyg.sixg.entry.AddressBean;
import com.hdyg.sixg.httpUtil.HttpCallback;
import com.hdyg.sixg.mvp.Contrant.CAddress;
import com.hdyg.sixg.mvp.base.BasePresenter;
import com.hdyg.sixg.util.ToastUtil;
import java.util.Map;

/**
 * @author CZB
 * @describe 收货地址
 * @time 2019/4/18 9:54
 */
public class PAddress extends BasePresenter implements CAddress.IPAddress {

    private CAddress.IVAddress mView;

    public PAddress(CAddress.IVAddress mView) {
        this.mView = mView;
    }


    @Override
    public void pGetAddress(String path, Map<String, String> params) {
        mModel.post(path, params, new HttpCallback<AddressBean>(true) {
            @Override
            public void onSuccess(AddressBean dataBean) {
                mView.vGetAddressSuccess(dataBean);
            }

            @Override
            public void onFail(String code, String error) {
                ToastUtil.show(error);
            }
        });
    }

    @Override
    public void pGetSaveAddress(String path, Map<String, String> params) {
        mModel.post(path, params, new HttpCallback(true) {
            @Override
            public void onSuccess(Object dataBean) {
                mView.vGetSaveAddressSuccess(dataBean.toString());
            }

            @Override
            public void onFail(String code, String error) {
                ToastUtil.show(error);
            }
        });
    }
}
